<template>
  <el-select style="width: 100%" v-model="operator" clearable filterable :placeholder="queryTItle"
             @change="selectSysEmployee" value-key="id">
    <el-option
      v-for="item in sysEmployeeList"
      :key="item.id"
      :label="item.name"
      :value="item">
    </el-option>
  </el-select>
</template>

<script>
  import {list as sysEmployeeList} from '@/api/sysEmployee'
  import utils from '../../utils/utils.js'
  export default{
    data(){
      return{
         query:{
           employeeId:''
         },
         sysEmployeeList:[],
        operator:''
      }
    },
    props:{
      queryTItle:{
        type:String,
        value:'请选择送货员'
      },
      operatorName:{
        type:String,
        value:''
      }
    },
    created() {
      this.operator=this.operatorName
      this.loadSysEmployee()
    },
    methods:{
      selectSysEmployee(data) {
        console.log(data)
        if(!utils.isNull(data)){
         this.query.employeeId = data.id
         this.query.name = data.name
        }else{
          this.query.employeeId = ''
          this.query.name = ''
        }
        this.$emit('queryEmployeeClick',this.query)
      },
      //  送货员
      loadSysEmployee() {
        var _this = this
        let params = new URLSearchParams();
        sysEmployeeList(params).then(response => {
          console.log(response);
          _this.sysEmployeeList = response.data.data
        }).catch(error => {
          console.log('error!!')
        });
      }
    }
  }
</script>

<style>
</style>
